home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0042_Get LEFT part of STRING.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  1KB  |  41 lines

  1. {*****************************************************************************
  2.  * Function ...... Left()
  3.  * Purpose ....... To return the left part of a string
  4.  * Parameters .... s         String to return the left part of
  5.  *                 n         Number of characters to return
  6.  * Returns ....... A string containing the <n> leftmost characters of <n>.
  7.  * Notes ......... None
  8.  * Author ........ Martin Richardson
  9.  * Date .......... October 2, 1992
  10.  *****************************************************************************}
  11. FUNCTION Left( s: STRING; n: BYTE ): STRING; ASSEMBLER;
  12. ASM
  13.       PUSH    DS
  14.  
  15.       LES     DI, @Result
  16.       LDS     SI, s
  17.       MOV     AL, n
  18.       CLD
  19.       XOR     CX, CX
  20.  
  21.       MOV     CL, BYTE PTR [SI]
  22.       INC     SI
  23.       CMP     CX, 0
  24.       JZ      @@2
  25.       CMP     AL, 0
  26.       JLE     @@1
  27.  
  28.       MOV    BYTE PTR ES:[DI], AL
  29.       INC    DI
  30.       MOV    CL, AL
  31.  
  32.       REP    MOVSB
  33.       JMP    @@3
  34.  
  35. @@1:  MOV     CL, 0
  36. @@2:  MOV     ES:[DI],CL
  37.  
  38. @@3:  POP     DS
  39. END;
  40.        
  41.